package com.woniuxy.dudugua.service.impl;

import com.woniuxy.dudugua.entity.Category;
import com.woniuxy.dudugua.entity.CategoryExample;
import com.woniuxy.dudugua.mapper.CategoryMapper;
import com.woniuxy.dudugua.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;
    @Override
    public List<Category> getOneType() {
        CategoryExample e = new CategoryExample();
        CategoryExample.Criteria c = e.createCriteria();

        c.andTypeEqualTo(1);
        List<Category> categories = categoryMapper.selectByExample(e);
        return categories;
    }

    @Override
    public List<Category> getChildType(int categoryid) {
        CategoryExample e = new CategoryExample();
        CategoryExample.Criteria c = e.createCriteria();
        CategoryExample.Criteria criteria = c.andPidEqualTo(categoryid);
        List<Category> categories = categoryMapper.selectByExample(e);
        return categories;
    }

    @Override
    public List<String> getCategory() {
        List<String> list = categoryMapper.selectCategory();
        return list;
    }
}
